package ynu.edu.entity;

import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import lombok.Getter;
import lombok.Setter;
import ynu.edu.common.entity.LogicEntity;

import javax.persistence.*;
import java.util.Set;

@Entity
@Getter
@Setter
public class Item extends LogicEntity {
    @Column
    private String itemName;
    @Column
    private String itemDescription;
    @Column
    private Double itemPrice;

    @Lob
    @Basic(fetch = FetchType.LAZY)
    @Column(name="itemImg", columnDefinition="longblob", nullable=true)
    private String itemImg;

    @ManyToOne(cascade = CascadeType.MERGE,fetch = FetchType.EAGER)
    @JoinColumn(name = "business_id")
    @JsonIgnoreProperties("items")
    private Business business;

    @OneToMany(cascade = CascadeType.ALL,fetch = FetchType.EAGER,orphanRemoval = true)
    @JoinColumn(name = "item_id")
    @JsonIgnoreProperties("item")
    private Set<ShopItem> shopItems;
}
